﻿using System.Collections.Generic;
using NetCore.Entities.LocationAreas;
using NetCore.LocationAreas.Dtos;
using AutoMapper;
using System.Linq;
using Abp.AutoMapper;

namespace NetCore.LocationAreas
{
    /// <summary>
    /// 区域DtoMapper
    /// </summary>
    public class LocationAreaDtoMapper : Profile
    {
        public LocationAreaDtoMapper()
        {
            CreateMap<LocationArea, LocationAreaDto>()
                .ForMember(m => m.ParentName, opt => opt.MapFrom(n => n.Parent.Name))
                .ForMember(m => m.ParentCode, opt => opt.MapFrom(n => n.Parent.Code))
            //chidren数据量太大...
            .ForMember(m => m.Chidren, opt => opt.MapFrom(n => n.Children.MapTo<List<LocationAreaDto>>()));

        }
    }
}
